﻿@using DCMS.Core
@using DCMS.Core.Infrastructure
@using DCMS.Web.Framework.UI
@using StackExchange.Profiling
@using DCMS.Core.Domain
@using DCMS.Core.Domain.Common
@using DCMS.Services.Events
@using DCMS.Services.Security
@using DCMS.Web.Framework.Events
@using DCMS.Services.Stores

@inject CommonSettings commonSettings
@inject IEventPublisher eventPublisher
@inject IPermissionService permissionService
@inject IWorkContext workContext
@inject StoreInformationSettings storeInformationSettings

@{
    var storeContext = EngineContext.Current.Resolve<IStoreContext>();
    var storeService = EngineContext.Current.Resolve<IStoreService>();
    var store = storeService.GetStoreById(storeContext?.CurrentStore?.Id ?? 0);
    Html.AddCssFileParts("~/css/style.css");
}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>@(Html.CurrentStoreTitle() + " - DCMS管理系统")</title>
    <meta name="keywords" content="@(Html.DCMSTitle(true))" />
    <meta name="description" content="@(Html.DCMSMetaDescription())">
    <meta name="author" content="DCMS">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    @*@await Component.InvokeAsync("Favicon")*@
    @*头部Css样式*@
    @Html.DCMSCssFiles(ResourceLocation.Head)
    @*头部Script脚本*@
    @Html.DCMSScripts(ResourceLocation.Head)
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="@Html.ResourceServerUrl("~/Scripts/libs/html5shiv.js")"></script>
    <script src="@Html.ResourceServerUrl("~/Scripts/libs/respond.min.js")"></script>
    <![endif]-->
    @{
        //X-UA-Compatible tag
        if (commonSettings.RenderXuaCompatible)
        {
            Html.AppendHeadCustomParts($"<meta http-equiv=\"X-UA-Compatible\" content=\"{commonSettings.XuaCompatibleValue}\"/>");
        }
        //event
        eventPublisher.Publish(new PageRenderingEvent(this.Html));

    }

    <style>
        body.sb-l-m .sidebar-menu > li.node-open {
            background-color: #4a89dc;
            color: #ffffff;
        }

            body.sb-l-m .sidebar-menu > li.node-open > span.glyphicons {
                color: #ffffff;
            }
    </style>


</head>

<body class="dashboard-page sb-l-o sb-r-c onload-check sb-l-m" id="layout-modal-content">
    @*页面通知提示*@
    @await Html.PartialAsync("_Notifications")

    <div id="main">

        @{ await Html.RenderPartialAsync("_Header"); }

        @await Component.InvokeAsync("LeftSidebar")

        @RenderBody()

        @{ await Html.RenderPartialAsync("_RightSidebar"); }

    </div>

    @*尾部部Css样式*@
    @Html.DCMSCssFiles(ResourceLocation.Footer)
    @if (IsSectionDefined("NewDefinFrameWorkScripts"))
    {
        @RenderSection("NewDefinFrameWorkScripts", false)
    }
    else
    {
        <!-- jQuery -->
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/jquery/jquery-1.11.1.min.js", order: 99);
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/jquery/jquery_ui/jquery-ui.min.js", order: 99);
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/bootstrap/bootstrap.min.js", order: 99);
    }

    @{

        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/jquery/jquery-1.11.1.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/jquery/jquery_ui/jquery-ui.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/jquery-ui-1.10.4.custom.js");

        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/globalize.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/moment.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/moment-with-locales.js");


        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/bootstrap/bootstrap.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/bootstrap/holder.min.js");

        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/jquery.PrintArea.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/print/LodopFuncs.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/jquery.validate.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/jquery.validate.unobtrusive.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/jquery.ztree.all-3.5.min.js");
        //Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/jquery.ztree.excheck.js");

        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Tables/jquery.treegrid.min.js");

        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Tables/bootstrap-table.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Tables/locale/bootstrap-table-zh-CN.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Tables/bootstrap-table-treeview.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Tables/editable/bootstrap-editable.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Tables/editable/bootstrap-table-editable.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Tables/bootstrap-table-treegrid.js");



        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/editors/ckeditor/ckeditor.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/editors/markitup/jquery.markitup.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/editors/markitup/sets/default/set.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/editors/summernote/summernote.js");

        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/circles/circles.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/colorpicker/js/bootstrap-colorpicker.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/datepicker/js/bootstrap-datetimepicker.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/daterange/daterangepicker.js");


        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/fancytree/jquery.fancytree.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/fancytree/jquery.fancytree.table.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/fancytree/jquery.fancytree-all.min.js"); //注释后商品等界面出错

        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/highcharts/highcharts.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/jquerymask/jquery.maskedinput.min.js");
        //Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/ladda/ladda.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/lazyline/jquery.lazylinepainter-1.5.0.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/lazyline/vendor/raphael-min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/magnific/jquery.magnific-popup.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/raphael/raphael.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/spin/spin.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/ladda/ladda.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/tagmanager/tagmanager.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/vendor/plugins/fileDownload/filedownload.js");

        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/admin-tools/admin-forms/js/additional-methods.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/admin-tools/admin-forms/js/advanced/steps/jquery.steps.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/admin-tools/admin-plugins/admin-panels/adminpanels.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/admin-tools/admin-plugins/admin-panels/jquery.ui.touch-punch.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/admin-tools/admin-plugins/admin-panels/json2.js");

        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/pages/login/EasePack.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/pages/login/login.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/pages/login/rAF.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/pages/login/TweenLite.min.js");

        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/utility/jquery.sparkline.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/utility/utility.js");


        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/main.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Toastr/Toastr.min.js");
        //Html.AddScriptParts(ResourceLocation.Footer, "~/js/stomp.min.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Boxer/jquery.fs.boxer.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/magnific-popup/jquery.magnific-popup.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/magnific-popup/magnific-popup.css");
        Html.AddScriptParts(ResourceLocation.Footer, "~/Scripts/Custom/Common.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/demo.js");
        Html.AddScriptParts(ResourceLocation.Footer, "~/assets/js/pages/widgets.js");
    }

    <!--MiniProfiler Start-->
    <mini-profiler position="RenderPosition.BottomRight" start-hidden="false" />

    <!--MiniProfiler End-->

    <!-- _FooterScript -->
    @*尾部Script脚本*@
    @Html.DCMSScripts(ResourceLocation.Footer)

    <!-- _Pushr -->
    @await Html.PartialAsync("_Pushr")

    @if (IsSectionDefined("CurPageScripts"))
    {
        @RenderSection("CurPageScripts", false)
    }

    @await Html.PartialAsync("_FooterScript")

    @*全局账户模板*@
    <script id="template-collection-accounts" type="text/x-tmpl">
        {% if(o.data!=null){ %}
        {% for (var i=0,option;option=o.data[i]; i++) { %}
        <span class="pull-left control-label mr10">{%=option.name%}:</span>
        <span class="pull-left">
            <input class="form-control-bb input-sm pbn pln prn" id="CollectionAmount_{%=option.Id%}" name="CollectionAmount" data-account="{%=option.Id%}" data-code="{%=option.code%}" data-codetype="{%=option.accountCodeTypeId%}" value="{%=option.value%}">
        </span>
        {% } %}
        {% } %}
    </script>

    @if (!store?.Setuped ?? false)
    {
        <!-- 初始向导 -->
        <div id="setupguide-modal-panel" class="popup-basic bg-none mfp-with-anim mfp-hide">
            <div class="panel">
                <div class="panel-heading">
                    <span class="panel-icon">
                        <i class="fa fa-cog"></i>
                    </span>
                    <span class="panel-title"> 欢迎使用DCMS经销商管理系统！</span>
                </div>
                <div class="panel-body" id="GuideForm1">
                    <div class="alert alert-danger alert-dismissable">
                        <i class="fa fa-warning pr10"></i>为了你快速上手系统的全部功能，请先手动初始化基础数据配置.
                    </div>
                    <hr class="short alt">
                    <form class="form-horizontal" method="get">
                        <ul class="fs14 list-unstyled list-spacing-10 mb10 ml15" style="list-style:decimal">
                            <li>
                                <span>会计科目初始</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_1"></i>
                            </li>
                            <li>
                                <span>商品类别初始</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_2"></i>
                            </li>
                            <li>
                                <span>品牌初始</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_3"></i>
                            </li>
                            <li>
                                <span>供应商初始</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_4"></i>
                            </li>
                            <li>
                                <span>备注初始</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_5"></i>
                            </li>
                            <li>
                                <span>商品单位初始</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_6"></i>
                            </li>
                            <li>
                                <span>仓库初始</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_7"></i>
                            </li>
                            <li>
                                <span>商品档案初始</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_8"></i>
                            </li>
                            <li>
                                <span>安装打印模板</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_9"></i>
                            </li>
                            <li>
                                <span>片区初始</span>
                                <i class="fa fa-exclamation-circle text-warning fa-lg pull-right" id="task_10"></i>
                            </li>
                        </ul>
                    </form>
                </div>
                <div class="panel-body" id="GuideForm2" style="display:none">
                    <div class="col-lg-8 col-lg-offset-2">
                        <p class="text-center">
                            <i class="fa fa-check-circle" style="font-size: 50px; color: #ff0000"></i>
                        </p>
                    </div>
                    <div class="col-lg-8 col-lg-offset-2">
                        <p class="text-center" style="font-size: 25px;">恭喜，初始安装完成！</p>
                    </div>
                </div>
                <div class="panel-footer">
                    <div class="row">
                        <div class="col-xs-6">
                            <a class="btn btn-info btn-block" href="http://docs.jsdcms.com" target="_blank">
                                <i class="fa fa-exclamation-circle fa-lg"></i>
                                用户向导
                            </a>
                        </div>
                        <div class="col-xs-6">
                            <button class="btn btn-primary btn-block" id="StartRunInit">初始化</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <script type="text/javascript">
            jQuery(document).ready(function () {
                "use strict";

                $.magnificPopup.open({
                    removalDelay: 500,
                    closeOnBgClick: false,
                    items: {
                        src: $('#setupguide-modal-panel')
                    },
                    overflowY: 'hidden',
                    callbacks: {
                        beforeOpen: function (e) {
                        }
                    },
                    midClick: false
                });

                var tasks = ["会计科目初始", "商品类别初始", "品牌初始", "供应商初始", "备注初始", "商品单位初始", "仓库初始", "商品档案初始", "安装打印模板", "片区初始"]
                var $order = 0;
                async function run() {
                    for (var i = 1; i <= tasks.length; i++) {
                        await $.ajax({
                            type: "post",
                            url: "/Install/Install?order=" + i,
                            //data: postData,
                            dataType: "json",
                            success: function (result) {
                                $order = result.Data;
                                if (result.Success) {
                                    $("#task_" + i).removeClass("fa-exclamation-circle").addClass("fa-check-circle");
                                    $("#task_" + i).removeClass("text-warning").addClass("text-primary");
                                }
                                else {
                                    $("#task_" + i).removeClass("fa-warning").addClass("fa-remove text-danger");
                                }
                            },
                            error: function () {
                                toastr.error('网络错误，请重新保存！');
                            }
                        });
                    }
                }
                //初始化
                $("#StartRunInit").click(function () {
                    $(this).html("<img src=\"http://resources.jsdcms.com/content/img/install-synchronizing.gif\" /> 初始中...")
                    $(this).addClass("disabled");

                    run().then(() => {
                        if ($order >= 9) {
                            $("#GuideForm1").hide();
                            $("#GuideForm2").show();
                            // 完成后自动跳转下一步
                            $("#btnNext").click();
                            $("#timedown").html(5);
                            $.ajax({
                                type: "post",
                                url: "/Install/ConfirmCompletion",
                                dataType: "json",
                                success: function (result) {
                                    window.location.href = "/";
                                },
                                error: function () {
                                    toastr.error('网络错误，请重新保存！');
                                }
                            });
                        }
                        else {

                        }
                    });
                });
            });
        </script>
    }

</body>
</html>

